//
//  FUIAlertView+defaultSetting.m
//  CoolMove
//
//  Created by CA on 15/3/29.
//  Copyright (c) 2015年 CA. All rights reserved.
//

#import "FUIAlertView+customizeAppearance.h"

@implementation FUIAlertView (customizeAppearance)

- (void)customizeAppearance
{
    self.titleLabel.textColor = kTWhiteText;
    self.titleLabel.font = kOpenSansFont(OpenSansExtraBold, 16.0);
    self.messageLabel.textColor = kTLightGray999;
    self.messageLabel.font = kOpenSansFont(OpenSansRegular, 14.0);
    self.backgroundOverlay.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.5f];
    self.alertContainer.backgroundColor = kSeparationLineColor;
    [self.alertContainer clipsCornerRadius:6.0f borderWidth:1.5 borderColor:kYellowGreenColor];
    self.defaultButtonColor = [UIColor clearColor];
    self.defaultButtonShadowHeight = 2.0f;
    self.defaultButtonShadowColor = [UIColor clearColor];
//    self.defaultButtonFont = [UIFont fontWithName:@"HelveticaNeue" size:15.0f];
    self.buttonsIsLandscape = YES;
    self.defaultButtonFont = kOpenSansFont(OpenSansExtraBold, 15.0);
    [self setButtonSpacing:12.0f];
    
    for (NSInteger i = 0; i < self.buttons.count; i++) {
        UIButton *button = [self.buttons objectAtIndex:i];
        [button clipsCornerRadius:3 borderWidth:1.5 borderColor:kYellowGreenColor];
        if (i == 0 && self.buttons.count == 2) {
            [button setTitleColor:kTWhiteText forState:UIControlStateNormal];
            button.backgroundColor = [UIColor clearColor];
        }else if ((i==0 && self.buttons.count == 1) || (i== 1 && self.buttons.count == 2)){
            
            [button setTitleColor:kTBlackText forState:UIControlStateNormal];
            button.backgroundColor = kYellowGreenColor;
        }
    }
    /*
     NSInteger index = 0;
     UIColor *boderColor = [UIColor colorWithHex:0x7c7b80 alpha:0.5];
     UIColor *titleColor = [UIColor colorWithHex:0x151515];
    for (UIButton *button in self.buttons) {
        button.layer.cornerRadius = 0;
        if (index == 0) {
            [button setTitleColor:titleColor forState:UIControlStateNormal];
            CALayer *lineLayer = [CALayer layer];
            lineLayer.backgroundColor = boderColor.CGColor;
            lineLayer.frame = CGRectMake(0, 0, button.bounds.size.width + 30, 0.5);
            [button.layer addSublayer:lineLayer];
        }else{
            CALayer *lineLayer = [CALayer layer];
            lineLayer.backgroundColor = boderColor.CGColor;
            lineLayer.frame = CGRectMake(0, 0, button.bounds.size.width, 0.5);
            lineLayer.hidden = YES;
            [button.layer addSublayer:lineLayer];
            CALayer *vLineLayer = [CALayer layer];
            vLineLayer.backgroundColor = boderColor.CGColor;
            vLineLayer.frame = CGRectMake(0, 0, 0.5, button.bounds.size.height);
            [button.layer addSublayer:vLineLayer];
            [button setTitleColor:kYellowGreenColor forState:UIControlStateNormal];
        }
        index++;
    }
     */
}

+ (FUIAlertView *)alertWithTitle:(NSString *)title
                       message:(NSString *)message
                   cancelTitle:(NSString *)cancelTitle
                  confirmTitle:(NSString *)confirmTitle
{
    FUIAlertView *alrtView = [[FUIAlertView alloc] initWithTitle:title message:message delegate:nil cancelButtonTitle:cancelTitle otherButtonTitles:confirmTitle, nil];
    [alrtView customizeAppearance];
    return alrtView;
}


@end
